import { mockApi } from "@/mock";
import type {
  DataSource,
  DataSourceQuery,
  DataSourceResponse,
  TableListResponse,
  ColumnInfo,
  TableDataQuery,
  TableDataResponse,
} from "@/types/dataSource";

export const getDataSourceList = (params: DataSourceQuery) => {
  return mockApi.getDataSourceList(params);
};

export const createDataSource = (data: Omit<DataSource, "id">) => {
  return mockApi.createDataSource(data);
};

export const updateDataSource = (id: number, data: Partial<DataSource>) => {
  return mockApi.updateDataSource(id, data);
};

export const deleteDataSource = (id: number) => {
  return mockApi.deleteDataSource(id);
};

export const testDataSourceConnection = (id: number) => {
  return mockApi.testDataSourceConnection(id);
};

export const getTableList = (
  dataSourceId: number
): Promise<TableListResponse> => {
  return mockApi.getTableList(dataSourceId);
};

export const getTableStructure = (
  dataSourceId: number,
  tableName: string
): Promise<ColumnInfo[]> => {
  return mockApi.getTableStructure(dataSourceId, tableName);
};

export const getTableData = (
  dataSourceId: number,
  tableName: string,
  query: TableDataQuery
): Promise<TableDataResponse> => {
  return mockApi.getTableData(dataSourceId, tableName, query);
};
